<template>
  <div id="app">
    <MyHeader title="购物车" color="#fff" backgroundColor="skyblue" />
    <MyGoods v-for="item in list" :key="item.id" :obj="item" />
    <MyFooter :arr="list" />
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader.vue";
import MyGoods from "./components/MyGoods.vue";
import MyFooter from "./components/MyFooter.vue";
export default {
  data() {
    return {
      list:[]
    };
  },

  // 组件注册
  components: {
    MyHeader,
    MyGoods,
    MyFooter,
  },

  // 以获取数据和方法
  created() {
    this.getCar();
  },

  // 定义方法
  methods: {
    async getCar() {
      const res = await this.$axios({
        url: "https://www.escook.cn/api/cart",
      });
      this.list = res.data.list;
    },
  },

  // 计算属性
  computed: {},

  // 监视数据
  watch: {},
};
</script>

<style scoped>
#app {
  padding: 45px 0;
}
</style>
